package com.bidevalution.business.impl;

import com.bidevalution.business.service.BidCaseStatService;
import com.bidevalution.dao.entity.SectionInfoResult;
import com.bidevalution.dao.mapper.BidCaseStatMapper;
import com.qtp.core.model.Paging;
import com.qtp.core.util.GsonUtil;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @Description 开评标情况统计接口实现类
 * @Date        2020-02-10 9:13
 * @Author      lhl
 */
@Log4j2
@Service
public class BidCaseStatServiceImpl implements BidCaseStatService {

    @Autowired(required = false)
    BidCaseStatMapper bidCaseStatMapper;

    @Override
    public Paging<SectionInfoResult> getSectionPaging(Map<String, Object> params) {
        long count = bidCaseStatMapper.getSectionCount(params);
        if (count == 0){
            return new Paging(0L,new ArrayList());
        }else {
            return new Paging(count,bidCaseStatMapper.getSectionList(params));
        }
    }

    @Override
    public Map<String, Object> getBidFileBrandStat(Map<String, Object> params) {
        log.info("LOG[]getBidDocSum[]{},params={}", "获取标书品牌汇总",GsonUtil.toJsonWithGson(params));
        try {
            return bidCaseStatMapper.getBidFileBrandStat(params);
        }catch (Exception e){
            log.error("LOG[]getBidDocSum[]{},error={},params={}","获取标书品牌汇总异常", GsonUtil.toJsonWithGson(e),GsonUtil.toJsonWithGson(params));
        }
        return null;
    }

    @Override
    public List<Map<String, Object>> getBidUnitList(Map<String, Object> params) {
        log.info("LOG[]getBidUnitList[]{},params={}", "获取投标明细",GsonUtil.toJsonWithGson(params));
        try {
            return bidCaseStatMapper.getBidUnitList(params);
        }catch (Exception e){
            log.error("LOG[]getBidUnitList[]{},error={},params={}","获取投标明细异常", GsonUtil.toJsonWithGson(e),GsonUtil.toJsonWithGson(params));
        }
        return null;
    }

    @Override
    public List<Map<String, Object>> getAreaProjectBidDetail(Map<String, Object> params) {
        log.info("LOG[]getAreaProjectBidDetail[]{},params={}", "获取某地区的项目投标明细",GsonUtil.toJsonWithGson(params));
        try {
            return bidCaseStatMapper.getAreaProjectBidDetail(params);
        }catch (Exception e){
            log.error("LOG[]getAreaProjectBidDetail[]{},error={},params={}","获取某地区的项目投标明细异常",GsonUtil.toJsonWithGson(e),GsonUtil.toJsonWithGson(params));
        }
        return null;
    }
}
